#define _CRT_SECURE_NO_WARNINGS 1
struct Node* copyRandomList(struct Node* head) {
    SL* cur = head;
    while (cur) {
        SL* copy = (SL*)malloc(sizeof(SL));
        copy->val = cur->val;
        copy->next = cur->next;
        cur->next = copy;
        cur = copy->next;
    }
    cur = head;
    while (cur) {
        SL* copy = cur->next;
        if (cur->random == NULL) {
            copy->random = NULL;
        }
        else {
            copy->random = cur->random->next;
        }
        cur = copy->next;
    }
    SL* newhead = NULL, * tail = NULL;
    cur = head;
    while (cur) {
        SL* copy = cur->next;
        cur->next = copy->next;
        if (tail == NULL) {
            newhead = tail = copy;
        }
        else {
            tail->next = copy;
            tail = copy;
        }
        cur = cur->next;
    }
    return newhead;
}